#!/bin/bash
mydir=`dirname "$0"`
uninstallToolPath="$mydir/UninstallerTool"
installBasePath="${2}"
installSubPath="."
payloadFile="${PACKAGE_PATH}/../../Resources/Payloads/PluralEyes4App.app.3297c80d.pax.gz"
productName="PluralEyes4"
productNumber="116"
installProductStr=`/usr/bin/grep -i "\<${productName}\>" "/tmp/rgs.C867B87B_3A5F_42DF_A83E_089FEDA01D63_${productNumber}"`
if [ ! -z "${installProductStr}" ]; then
    /usr/bin/xattr -d com.apple.quarantine "${payloadFile}"
    /bin/mkdir -p "$2/${installSubPath}"
    pushd "$2/${installSubPath}"
    /bin/pax -rzf "${payloadFile}"
    popd
    "$uninstallToolPath" -a "shootersuite" "Shooter Suite" -a "shootersuite.pluraleyes4" "PluralEyes4" "${installBasePath}/${installSubPath}/PluralEyes 4.app"
    if [ -x "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister" ]; then
        "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister" "$2/${installSubPath}/PluralEyes 4.app"
    fi
    if [ -x "/usr/bin/pluginkit" ]; then
        pushd "$2/${installSubPath}/"
        if [ -d "PluralEyes 4.app/Contents/PlugIns" ]; then
            "/usr/bin/pluginkit" -a "PluralEyes 4.app/Contents/PlugIns/*"
            fi
        popd
    fi
fi
